package com.genius.smsdao.attendancemanage.domain;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.genius.smsbase.Domain.BaseEntity;
import com.genius.smsdao.coursemanage.domain.Course;
import com.genius.smsdao.studentmanage.domain.Student;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @Entity:Attendance  考勤实体类
 * 对应数据库表名：attendance
 * @author：liangwei
 */
@Entity
@Table(name = "attendance")
public class Attendance extends BaseEntity<Long> {

    @Column
    private String name;

    //考勤到考勤方式多对一的关系
    @JsonIgnoreProperties(value = "attendanceList")
    @ManyToOne(targetEntity = Way.class,fetch = FetchType.LAZY)
    @JoinColumn(name = "way_id",referencedColumnName = "id")
    private Way way;

    //考勤到课程一对多的关系，课程被考勤
    @JsonIgnoreProperties(value = "attendance")
    @OneToMany(mappedBy = "attendance",cascade = {CascadeType.REMOVE,CascadeType.REFRESH},fetch = FetchType.LAZY)
    private List<Course> courseList;

    //考勤到学生一对多关系， 学生被考勤
    @JsonIgnoreProperties(value = "attendance")
    @OneToMany(mappedBy = "attendance",cascade = {CascadeType.REMOVE,CascadeType.REFRESH},fetch = FetchType.LAZY)
    private List<Student> studentList;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Way getWay() {
        return way;
    }

    public void setWay(Way way) {
        this.way = way;
    }

    public List<Course> getCourseList() {
        return courseList;
    }

    public void setCourseList(List<Course> courseList) {
        this.courseList = courseList;
    }

    public List<Student> getStudentList() {
        return studentList;
    }

    public void setStudentList(List<Student> studentList) {
        this.studentList = studentList;
    }

    @Override
    public String toString() {
        return "Attendance{" +
                "name='" + name + '\'' +
                ", way=" + way +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", id=" + id +
                '}';
    }
}


